FROM jenkins/jnlp-slave:3.35-5-alpine

USER root
RUN apk add docker

ENV GRADLE_VERSION=5.6.2

RUN wget -q -O /tmp/gradle-bin.zip https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip && \
    mkdir -p /opt/gradle && \
    unzip -q /tmp/gradle-bin.zip -d /opt/gradle && \
    ln -sf /opt/gradle/gradle-$GRADLE_VERSION/bin/gradle /usr/local/bin/gradle && \
    rm -f /tmp/gradle-bin.zip && \
    chown -R jenkins:root /opt/gradle && \
    chmod -R g+rw /opt/gradle

USER jenkins

ENTRYPOINT ["jenkins-slave"]